<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport"
          content="width=device-width,user-scalable=no, initial-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>预签约确认</title>
    <%- include('./_global/baseLibs') %>
    <link rel="stylesheet"  href="/static/css/mycontract.css" />
</head>
<style>
    html,body {
        background: #fff;
    }
    .tcxx{
        display: block!important;
    }
    .fwtc-choose-box {
        background: #fff;
        width: 1.45rem;
        height: 1.45rem;
        border: 1px solid #a19e9a;
        margin-top: 0px;
        clear: both;
        float: none;
    }
    .fwtc-choose-box:checked{
        background: url("/static/images/yes-blue.png") no-repeat 15%;
        background-size: contain;
    }
</style>
<body>
<section class="page-wrap yqy-page">
    <header class="header-box grey fixed">
        <div class="header-content">
            <div class="left-tool">
                <a class="back" href="javascript:void(0);"><i class="iconfont icon-back"></i></a>
            </div>
            <div class="title">预签约确认</div>
        </div>
    </header>
    <div class="yqy-box">
        <ul>
            <li><span class="black-text">个人信息：</span>
                <p>
                    <span class="text-left">姓名：</span> <span id="XM"></span>
                </p>
                <p>
                    <span class="text-left">身份证号：</span> <span id="SFZH"></span>
                </p>
                <p>
                    <span class="text-left">社保卡号：</span> <span id="SBKH"/></span>
                </p>
                <p>
                    <span class="text-left">手机号：</span> <span id="DHHM"/></span>
                </p>
                <!-- <p>
                    <span class="text-left">社保卡号：</span> <input id="SBKH"/>
                </p>
                <p>
                    <span class="text-left">手机号：</span> <input id="DHHM"/>
                </p> --></li>
            <li><span class="black-text">签约信息：</span>
                <p>
                    <span class="text-left">签约团队：</span>
                    <span id="TDMC"></span>
                </p>
                <p>
                    <span class="text-left">签约服务：</span>
                    <span style="display: inline-block;" id="TCMC">
					</span>
                </p>
                <p>
                    <span class="text-left">签约总价：</span> <span id="TCZJ"></span>
                </p>
                <p style="margin-top: 10px;">
                    <span class="text-left">服务协议：</span><input type="checkbox"
                                                               class="fwtc-choose-box" /> <span>勾选表示同意服务协议</span> <a class="qyxq">详情<i></i></a>
                </p></li>
        </ul>
    </div>
    <div class="tj-btn-box">
        <a class="qd-btn">确定</a>
    </div>
</section>
</body>
<script type="text/javascript">



    function LowerJSONKey(jsonObj){
        for (var key in jsonObj){
            jsonObj[key.toLowerCase()] = jsonObj[key];
            delete(jsonObj[key]);
        }
        return jsonObj;
    }


    var page_yqyqr = (function($, page_yqyqr) {

        function initView() {
            /**确认预签约信息*/
            $(".qd-btn").on("click", function() {
                if (page_yqyqr.validate()) {
                    var QYXX = page_yqyqr.getqyxx();
                    var JMXX = page_yqyqr.getjmxx();
                    var param = page_yqyqr.getSubmitInfo(JMXX,QYXX);
                    console.log(param);
                    /**提交预签约请求*/
                    $.QuickRemote.AjaxJson({
                        funcName:"/api/gzd/qyfw/addYqyToJkcs",
                        callback:page_yqyqr.saveYqyxxHandler,
                        params:param
                    });
                }else{
                    $.QuickAlert.alertFail({content: "请勾选服务协议"});
                }
            });

            // 大写转小写
            function LowerJSONKey(jsonObj){
                for (var key in jsonObj){
                    jsonObj[key.toLowerCase()] = jsonObj[key];
                    delete(jsonObj[key]);
                }
                return jsonObj;
            }

            /**查看服务协议*/
            $(".qyxq").on("click", function() {
                StoreCache.setCache("isSelectFwxy", page_yqyqr.validate());
                $.QuickUrlUtils.redirectJSBridge({url:"/html/common/signService/yqyxq.html",title:"服务协议详情"});
            });
        }
        function getqyxx(){
            var QYFW_TDXX = StoreCache.getCache("QYFW_TDXX");
            var now = new Date();
            var qysj = now.Format("yyyy-MM-dd HH:mm:ss");
            var sxsj = qysj;
            now.setYear(now.getFullYear() + 1);
            var jssj = now.Format("yyyy-MM-dd HH:mm:ss");
            var QYXX = {};
            QYXX['yltdid'] = QYFW_TDXX.tdid;//必须
            QYXX['qysj'] = qysj;//必须,签约时间
            QYXX['sxsj'] = sxsj;//必须,生效时间
            QYXX['jssj'] = jssj;//必须,结束时间
            QYXX['qyfy'] = $("#TCZJ").text();
            return QYXX;
        }
        function  getjmxx() {
            var QYFW_HZXX = StoreCache.getCache("jkcsUserInfo");
            console.log(JSON.stringify(QYFW_HZXX));
            var jmxx = {};
            jmxx["jmxxid"] = QYFW_HZXX.userid;//必须
            jmxx["xm"] = QYFW_HZXX.xm;//必须
            jmxx["sfzh"] = QYFW_HZXX.sfzh;//必须
            jmxx["zjhm"] = QYFW_HZXX.sfzh;//必须
            jmxx["zjlx"] = "01"//QYFW_HZXX.patientCardType;//必须
            jmxx["sjhm"] = QYFW_HZXX.sj;
            jmxx["lxdh"] = QYFW_HZXX.sj;
            jmxx["jtzz"] = ""//QYFW_HZXX.address||"";
            jmxx["xb"] = QYFW_HZXX.xb;
            var dateString = QYFW_HZXX.sfzh;
            dateString = dateString.substring(6,10) + "-" + dateString.substring(10,12) + "-" + dateString.substring(12,14);
            jmxx["csrq"] = dateString;

            return jmxx;
        }
        function getSubmitInfo(JMXX,QYXX) {
            var QYFW_TDXX = StoreCache.getCache("QYFW_TDXX");
            var QYFW_HZXX = StoreCache.getCache("jkcsUserInfo");
            var QYFWBXX = $("#TCMC").data("FWTCDM");
            var QYFWBSX = $("#TCMC").data("FWTCSX");
            var param = new Object();
//        var param = {};
//        var  JMXX=LowerJSONKey(JMXX);
//        var  QYXX=LowerJSONKey(QYXX);
//        console.log("JMXX"+JSON.stringify(JMXX));
//        console.log("QYXX"+JSON.stringify(QYXX));
            param["zjhm"] = QYFW_HZXX.sfzh;//必须
            param["qylx"] = "00";//预签约类型
//        param['JMXX']=JSON.stringify(JMXX);//必须
//        param['QYXX']=JSON.stringify(QYXX);//必须
            page_yqyqr.addOjb(param, JMXX, "jmxx");
            page_yqyqr.addOjb(param, QYXX, "qyxx");
            param['yljgid']=QYFW_TDXX.yljgid;//必须
            param['qyfwbxx']=QYFWBXX;//必须
            param['qyfwbsx']=QYFWBSX;
            param["usid"] = "";
            return param;

        }

        function addOjb(param, obj, col){
            for(var key in obj){
                param[col+"."+key] = obj[key];
            }
        }

        function initData() {
            page_yqyqr.setUserInfo();
            /**获取团队信息*/
            var tdxx = StoreCache.getCache("QYFW_TDXX");
            /**加载团队信息*/
            page_yqyqr.tdxxLoad(tdxx);
            /**获取套餐信息*/
            var tcxx = StoreCache.getCache("QYFW_SELECTED_TCXX");
            /**加载套餐信息*/
            page_yqyqr.tcxxLoad(tcxx);
            /**判断服务协议是否被选中*/
            var isSelectFwxy = StoreCache.removeCache("isSelectFwxy");
            $(".fwtc-choose-box").prop("checked", isSelectFwxy);

        }

        /**设置用户可见信息*/
        function setUserInfo() {
            var result = StoreCache.getCache("jkcsUserInfo");
            console.log(result);

            $("#XM").text(result["xm"]);
            $("#SFZH").text(result["sfzh"]);
            $("#SBKH").text(result["sbkh"]||"");
            $("#DHHM").text(result["sj"]||"");
        }

        /**校验是否选中勾选协议*/
        function validate() {
            return $("input.fwtc-choose-box").prop("checked");
        }
        /**加载套餐信息*/
        function tcxxLoad(tcxx) {
            if(!StringUtils.isEmpty(tcxx)){
                var tcmc = "",tczj = 0,tcdm = "",tcsx = "";
                $(tcxx).each(function(index, item){
                    tcmc += ("<span class='tcxx'>" + item["fwbmc"] + "\n" + item["fwmcs"] + item["fwnrs"] + "一签</span>");
                    tczj += parseInt(item["fy"]);
                    tcdm += item["fwbid"] + ","
                    tcsx += 1 + ","
                });
                $("#TCMC").html(tcmc.substr(0,tcmc.length - 1));
                /**这里的套餐代码指多个代码*/
                $("#TCMC").data({FWTCDM : tcdm.substr(0,tcdm.length - 1)
                    ,FWTCSX : tcsx.substr(0,tcdm.length - 1)});
                $("#TCZJ").text(tczj);
            }
        }
        /**加载团队信息*/
        function tdxxLoad(tdxx){
            if(tdxx){
                $("#TDMC").text(tdxx["tdmc"]);
                $("#TDMC").data({
                    YYDM : tdxx["yydm"],
                    TDDM : tdxx["tddm"]
                });
            }
        }

        /**预签约回调*/
        function saveYqyxxHandler(result){
            if(result.state == "true" || result.state == true){
                $.QuickAlert.alertNormal("预签约成功!",{callback:function(){
                    $.QuickUrlUtils.redirectJSBridge({url:"/html/common/signService/qyls.html",title:"签约历史"});
                }});
            }else{
                $.QuickAlert.alertFail({content : result.info});
            }
        }

        var cfg_def = {
            initView: initView,
            initData: initData,
            getqyxx: getqyxx,
            getjmxx: getjmxx,
            getSubmitInfo: getSubmitInfo,
            addOjb: addOjb,
            setUserInfo: setUserInfo,
            validate: validate,
            tcxxLoad: tcxxLoad,
            tdxxLoad: tdxxLoad,
            saveYqyxxHandler: saveYqyxxHandler,
        }

        page_yqyqr.init = function(cfg){
            $.extend(page_yqyqr, cfg_def, cfg);
            page_yqyqr.initView();
            page_yqyqr.initData();

        }

        return page_yqyqr;
    })(jQuery, {});
    
</script>

</html>









